Skip to content

feat: add mail draft subcommand#5

Open
errazuriz wants to merge 1 commit intojaredpalmer:mainfrom
errazuriz:feat/mail-draft
Open

feat: add mail draft subcommand#5
errazuriz wants to merge 1 commit intojaredpalmer:mainfrom
errazuriz:feat/mail-draft

Conversation

@errazuriz
Copy link
Copy Markdown

Summary

  • Adds mog mail draft subcommand to create draft messages via Graph API (POST /me/messages)
  • Recipients are optional — drafts can be created without --to and completed later in Outlook
  • Includes --dry-run support following the existing pattern
  • Uses Mail.ReadWrite scope (required for creating messages)
  • Supports both delegated and app-only auth modes

Usage

# With recipients
mog mail draft --subject "Subject" --to recipient@example.com --body "Body text"

# Without recipients (complete later in Outlook)
mog mail draft --subject "Subject" --body "Body text"

# Preview
mog mail draft --subject "Subject" --to recipient@example.com --dry-run

Changes

  • internal/services/mail/service.go: Add Draft() method and draftMailScopes
  • internal/cmd/mail.go: Add MailDraftCmd struct and Run() method
  • internal/cmd/runtime.go: Add capMailDraft capability constant and rule
  • internal/cmd/mail_test.go: Add flag parsing tests (with and without recipients)

Test plan

  • All existing tests pass (go test ./...)
  • New tests: TestMailDraftFlagParsesWithoutTo, TestMailDraftFlagParsesWithTo
  • --dry-run verified manually
  • --help output verified

🤖 Generated with Claude Code

Add `mog mail draft` to create draft messages via Graph API POST to
/me/messages. Recipients are optional so drafts can be completed in
Outlook. Includes --dry-run support and tests for flag parsing.

Uses Mail.ReadWrite scope (required for creating messages).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant